package service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import dao.FoodDao;
import pojo.Categories;
import pojo.Food;
import pojo.Merchant;
import service.FoodService;

@Service
@Transactional
public class FoodServiceImpl implements FoodService {
	
	@Resource(name="foodDaoImpl")
	private FoodDao foodDao;
	
	@Override
	public List<Food> findByMerchant(String mId, int current, int pageSize) {
		
		return null;
	}

	
	@Override
	public List<Food> findFood(String tId,String mId){
		List<Food> foodList = new ArrayList<Food>();
		if("all".equals(tId)){
			foodList = foodDao.findByMerchant(mId);
		}else{
			foodList = foodDao.findByCategory(mId, tId);
		}
		return foodList;
	}

	@Override
	public Food delete(String id) {
		return foodDao.delete(id);
	}

	@Override
	public Food load(String id) {
		return foodDao.load(id);
	}

	@Override
	public Food update(Food food) {
		return foodDao.update(food);
	}


	@Override
	public void add(Categories categories, Merchant merchant) {
		foodDao.add(categories,merchant);
	}
	
}
